<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/CustomCommand.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/DaoFactory.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/entity/User.php';

	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	
	/*
	* Class to validate a credential
	*/
	class CommandCreateUser extends CustomCommand {
		/*
		* Constructor of the class
		*/
		public function __construct($pkUsername,$password,$firstName,$secondName,$firstLastName,$secondLastName,$emailAddress,$fkIdRole)       {
			
			$this -> user = new User($pkUsername,$password,$firstName,$secondName,$firstLastName,$secondLastName,$emailAddress,$fkIdRole);
		
		}
		
		/*
		* Method to execute to validate the credential
		*/
		public function execute() {
			//Ir contra el DAO con este query

			$daoFactory= DaoFactory:: getMySqlDaoFactory();
			$iuad= $daoFactory -> getMySqlUserAccessDao();		
			$success=$iuad -> createUser($this -> user);

			//Si existe la credencial el resultado es true
			$this -> result = $success;
		}
	}
?>